package org.ediba.siri.web.rest;

import java.beans.PropertyEditorSupport;
import org.json.JSONException;
import org.json.JSONObject;

public class JSONPropertyEditor extends PropertyEditorSupport {
	
	@Override
	public void setAsText(String text) throws IllegalArgumentException {
		JSONObject jsonObject = null;
		try {jsonObject = new JSONObject(text);}
		catch (JSONException e) {e.printStackTrace();}
		this.setValue(jsonObject);
	}
	
	@Override
	public String getAsText() {
		return this.getValue().toString();
	}

}
